package com.shoeshopping.action.zx;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.shoeshopping.formbean.zx.AdminForm;
import com.shoeshopping.service.zx.AdminService;
import com.shoeshopping.utils.zx.Result;

@Controller("adminAction")
public class AdminAction extends ActionSupport implements ModelDriven<AdminForm>{

	AdminForm dataForm = new AdminForm();

	@Resource
	AdminService adminService;
	
	public String login(){
		if(adminService.login(dataForm) == true){
			return Result.LOGIN;
		}
		return Result.ERROR;
	}
	
	public String logout(){
		if(adminService.logout() == true){
			return Result.LOGOUT;
		}
		return Result.ERROR;
	}
	
	public String changePassword(){
		if(adminService.changePassword(dataForm) && adminService.logout()){
			return Result.CHANGEPASSWPRD;
		}
		return Result.ERROR;
	}
	@Override
	public AdminForm getModel() {
		return dataForm;
	}
}
